POV-Ray : Newsgroups : povray.advanced-users : Array irritation. : Re: Array irritation. Server Time
30 Jul 2024 04:18:14 EDT (-0400)
  Re: Array irritation.  
From: Thorsten Froehlich
Date: 19 Oct 2000 01:28:45
Message: <39ee868d$1@news.povray.org>
In article <39ed87d0@news.povray.org> , Warp <war### [at] tagpovrayorg>  wrote:

> (supposing that 'var' is an unsigned int of size 32 bits)
> to this (in assembler):

Ah, so you are learning assembler (variants) now...

> rol [Variable], 5
>
> (ie. "rotate the value [Variable] to the left 5 positions").

Just curious, which architecture were you compiling for here?

>   In C there's no operation to rotate values like in most assemblers so you
> have to do it with two shifts and one or.

Yes, and there are many more tricks:

main:
 addi $0, $0, 10
 addi $1, $1, 15
 andi $2, $2, 0
 andi $3, $3, 0
for:
 andi $2, $2, 0
 beq  $0, $2, ret
 srl1 $0, $0
 sll1 $1, $1
 andi $2, $0, 1
 subi $2, $2, 1
 not  $2, $2
 and  $2, $1, $2
 add  $3, $3, $2
 j    for
ret:
 j    ret


Assume j is a unconditional jump, and srl1/sll1 are logical right/left
shifts by one bit.  Further assume all values are unsigned 8 bit ints.  $0
to $3 are registers (MIPS assembly notation), your input is in $0 and $1,
and the result is in $2.

What is this program doing?


   Thorsten


____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.